package core;

import gui.common.*;
/** The Unit enumerations used to specify which type of units will be associated with the count
 * 	in the Amount object
 * @see Amount
 *
 */
public enum Unit {
	count, 
	pounds, 
	ounces, 
	grams, 
	kilograms, 
	gallons, 
	quarts, 
	pints, 
	fluidOunces, 
	liters;
	
	public SizeUnits toSizeUnits()
	{
		if(this == Unit.count)
			return SizeUnits.Count;
		else if(this == Unit.pounds)
			return SizeUnits.Pounds;
		else if(this == Unit.ounces)
			return SizeUnits.Ounces;
		else if(this == Unit.grams)
			return SizeUnits.Grams;
		else if(this == Unit.kilograms)
			return SizeUnits.Kilograms;
		else if(this == Unit.gallons)
			return SizeUnits.Gallons;
		else if(this == Unit.quarts)
			return SizeUnits.Quarts;
		else if(this == Unit.pints)
			return SizeUnits.Pints;
		else if(this == Unit.fluidOunces)
			return SizeUnits.FluidOunces;
		else
			return SizeUnits.Liters;
	}
	
	public String toString()
	{
		if(this == Unit.count)
			return "count";
		else if(this == Unit.pounds)
			return "pounds";
		else if(this == Unit.ounces)
			return "ounces";
		else if(this == Unit.grams)
			return "grams";
		else if(this == Unit.kilograms)
			return "kilograms";
		else if(this == Unit.gallons)
			return "gallons";
		else if(this == Unit.quarts)
			return "quarts";
		else if(this == Unit.pints)
			return "pints";
		else if(this == Unit.fluidOunces)
			return "fluidOunces";
		else
			return "liters";
	}
	
	/**
	 * Get the type of unit that this is
	 * 
	 * @return UnitType.  Weight, count, or volume.
	 */
	public UnitType getUnitType()
	{
		if (this == Unit.count)
		{
			return UnitType.Count;
		}
		else if ((this == Unit.pounds) || (this == Unit.ounces) || 
				 (this == Unit.grams) || (this == Unit.kilograms))
		{
			return UnitType.Weight;
		}
		else /*if ((this == Unit.gallons) || (this == Unit.quarts) || (this == Unit.pints) || 
				 (this == Unit.fluidOunces) || (this == Unit.liters))*/
		{
			return UnitType.Volume;
		}
	}
	
	public static Unit createUnit(String unit)
	{
		if(unit.equals("count"))
			return Unit.count;
		else if(unit.equals("pounds"))
			return Unit.pounds;
		else if(unit.equals("ounces"))
			return Unit.ounces;
		else if(unit.equals("grams"))
			return Unit.grams;
		else if(unit.equals("kilograms"))
			return Unit.kilograms;
		else if(unit.equals("gallons"))
			return Unit.gallons;
		else if(unit.equals("quarts"))
			return Unit.quarts;
		else if(unit.equals("pints"))
			return Unit.pints;
		else if(unit.equals("fluidOunces"))
			return Unit.fluidOunces;
		else
			return Unit.liters;
	}
}
